﻿Imports System.Net.Sockets
Imports System.Threading
Class ConnectionQueue

    Dim transfers As ArrayList = New ArrayList()
    Public started As Boolean = True

    Function findWaiting() As ArrayList
        Dim ret As ArrayList = New ArrayList()
        For Each t As transfer In transfers
            If t.waiting Then
                ret.Add(t)
            End If
        Next
        Return ret
    End Function

    Sub addTransfer(ByVal transfer As transfer)
        transfers.Add(transfer)
    End Sub

    Sub sortClient(ByVal uID As Integer, ByVal orderNum As Integer, ByVal client As tcpclient)
        For Each t As transfer In transfers
            If (t.uID = uID) Then
                t.add(client, orderNum)
                Exit For
            End If
        Next
    End Sub

    Function contains(ByVal uID As Integer) As Boolean
        For Each t As transfer In transfers
            If t.uID = uID Then
                Return True
            End If
        Next
        Return False
    End Function

    Sub removeFinished()
        Try
            For Each t As transfer In transfers
                If (t.complete) Then
                    transfers.Remove(t)
                End If
            Next
        Catch e As exception
        End Try
    End Sub

End Class
